// components/dropDown-popup/dropDown-popup.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        popupName: {

        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        filterActiv: null,
        flag: false,
        triangle: '/static/triangle.png',
        triangle_Activ: '/static/triangle-activ.png',
        searchConfig: [
            {
                type: "classify",
                name: "油品",
                default: "油品",
                code: "secondClassifyId",
                value: ""
            }, {
                type: "classifyStandard",
                default: "国标",
                name: "国标",
                code: "standardType",
                value: ""
            }, {
                type: "oilProvinceAll",
                default: "油库",
                name: "油库",
                code: "oilHouseId",
                value: ""
            }, {
                type: "dict:trade_type",
                default: "模式",
                name: "模式",
                code: "tradeType",
                value: ""
            }
        ],
        testStorehouse: [
            {
                city: '全部',
                info: [
                    '全部',
                    '宝山区石洞口库',
                    '中石化上海石化储运部',
                    '中石化闵行油库',
                    '金山区油库',
                    '玉带油库',
                    '栖霞油库',
                    '南通华盛油库',
                    '东恒油库',
                    '新世纪油库',
                    '中石化义乌油库',
                    '台州前所油库',
                    '龙湾油库',
                    '宁波油库',
                    '滨海油库',
                    '状元油库',
                    '中石化厦门海澳油库',
                    '翁墩油库（南平）',
                    '石湖油库',
                    '古杉油库',
                    '江阴闽海油库',
                    '铜陵油库',
                    '中石化油库',
                    '邵武油库',
                    '中石油厦门库',
                    '泉州石井海滨油库',
                    '江阴（富海）油库',
                    '琯头油库',
                    '赛岐油库',
                    '泉港油库',
                    '长乐后安油库',
                    '水北油库',
                    '兴闽油库',
                    '港务油库',
                    '东坑油库',
                    '福海创古雷工厂',
                    '博坦油库',
                    '中化泉州炼厂库',
                    '大华油库',
                    '东孚油库',
                    '漳湾油库',
                    '红山油库',
                    '江阴中远海运油库',
                    '苏闽油库',
                    '海澳油库',
                    '翁墩油库'
                ],
            },
            {
                city: '上海市',
                info: [
                    '宝山区石洞口库',
                    '中石化上海石化储运部',
                    '中石化闵行油库',
                    '金山区油库',
                ],
            },
            {
                city: '江苏省',
                info: [
                    '玉带油库',
                    '栖霞油库',
                    '南通华盛油库',
                ],
            },
            {
                city: '浙江省',
                info: [
                    '东恒油库',
                    '新世纪油库',
                    '中石化义乌油库',
                    '台州前所油库',
                    '龙湾油库',
                    '宁波油库',
                    '滨海油库',
                    '状元油库',
                ],
            },
            {
                city: '福建省',
                info: [
                    '中石化厦门海澳油库',
                    '翁墩油库（南平）',
                    '石湖油库',
                    '古杉油库',
                    '江阴闽海油库',
                    '铜陵油库',
                    '中石化油库',
                    '邵武油库',
                    '中石油厦门库',
                    '泉州石井海滨油库',
                    '江阴（富海）油库',
                    '琯头油库',
                    '赛岐油库',
                    '泉港油库',
                    '长乐后安油库',
                    '水北油库',
                    '兴闽油库',
                    '港务油库',
                    '东坑油库',
                    '福海创古雷工厂',
                    '博坦油库',
                    '中化泉州炼厂库',
                    '大华油库',
                    '东孚油库',
                    '漳湾油库',
                    '红山油库',
                    '江阴中远海运油库',
                    '苏闽油库',
                    '海澳油库',
                    '翁墩油库'
                ]
            },
            {
                city: '上海市',
                info: [
                    '宝山区石洞口库',
                    '中石化上海石化储运部',
                    '中石化闵行油库',
                    '金山区油库',
                ],
            },
            {
                city: '江苏省',
                info: [
                    '玉带油库',
                    '栖霞油库',
                    '南通华盛油库',
                ],
            },
            {
                city: '浙江省',
                info: [
                    '东恒油库',
                    '新世纪油库',
                    '中石化义乌油库',
                    '台州前所油库',
                    '龙湾油库',
                    '宁波油库',
                    '滨海油库',
                    '状元油库',
                ],
            },
            {
                city: '福建省',
                info: [
                    '中石化厦门海澳油库',
                    '翁墩油库（南平）',
                    '石湖油库',
                    '古杉油库',
                    '江阴闽海油库',
                    '铜陵油库',
                    '中石化油库',
                    '邵武油库',
                    '中石油厦门库',
                    '泉州石井海滨油库',
                    '江阴（富海）油库',
                    '琯头油库',
                    '赛岐油库',
                    '泉港油库',
                    '长乐后安油库',
                    '水北油库',
                    '兴闽油库',
                    '港务油库',
                    '东坑油库',
                    '福海创古雷工厂',
                    '博坦油库',
                    '中化泉州炼厂库',
                    '大华油库',
                    '东孚油库',
                    '漳湾油库',
                    '红山油库',
                    '江阴中远海运油库',
                    '苏闽油库',
                    '海澳油库',
                    '翁墩油库'
                ]
            },
            {
                city: '上海市',
                info: [
                    '宝山区石洞口库',
                    '中石化上海石化储运部',
                    '中石化闵行油库',
                    '金山区油库',
                ],
            },
            {
                city: '江苏省',
                info: [
                    '玉带油库',
                    '栖霞油库',
                    '南通华盛油库',
                ],
            },
            {
                city: '浙江省',
                info: [
                    '东恒油库',
                    '新世纪油库',
                    '中石化义乌油库',
                    '台州前所油库',
                    '龙湾油库',
                    '宁波油库',
                    '滨海油库',
                    '状元油库',
                ],
            },
            {
                city: '福建省',
                info: [
                    '中石化厦门海澳油库',
                    '翁墩油库（南平）',
                    '石湖油库',
                    '古杉油库',
                    '江阴闽海油库',
                    '铜陵油库',
                    '中石化油库',
                    '邵武油库',
                    '中石油厦门库',
                    '泉州石井海滨油库',
                    '江阴（富海）油库',
                    '琯头油库',
                    '赛岐油库',
                    '泉港油库',
                    '长乐后安油库',
                    '水北油库',
                    '兴闽油库',
                    '港务油库',
                    '东坑油库',
                    '福海创古雷工厂',
                    '博坦油库',
                    '中化泉州炼厂库',
                    '大华油库',
                    '东孚油库',
                    '漳湾油库',
                    '红山油库',
                    '江阴中远海运油库',
                    '苏闽油库',
                    '海澳油库',
                    '翁墩油库'
                ]
            },
        ],
        storeActiv: null,
        storeIndex: 0,
        storeLev2: [],
        selectName: '',

        oilQuality: [
            {
                oilType: '全部',
                oilNum: [
                    '全部',
                    '-35#',
                    '-25#',
                    '-10#',
                    '3#',
                    '0#',
                    'E98#',
                    'E95#',
                    'E92#',
                    '101#',
                    '95#',
                    '92#',
                    '98#'
                ]
            }, {
                oilType: '车用汽油',
                oilNum:[
                    '全部',
                    '101#',
                    '95#',
                    '92#',
                    '98#'
                ]
            }, {
                oilType: '车用柴油',
                oilNum:[
                    '全部',
                    '-35#',
                    '-25#',
                    '-10#',
                    '0#'
                ]
            },{
                oilType: '燃料油',
                oilNum:[
                    '全部',
                ]

            }
        ],
        oilActiv: null,
        oilLev2: [],
        oilIndex: 0,
        oilName:'',

        GB_oil:[
            '全部',
            '国标VI',
            '国标VIB',
            '国标V',
            '国标（VIA）/（VIB）',
            '国标VIA'
        ],
        buyName:'',
        companyActiv:null,

        model:[
            '全部',
            '锁涨不跌',
            '锁涨追跌'
        ],
        companyName:''
    },

    /**
     * 组件的方法列表
     */
    methods: {
        popup(e) {
            let _this = this;
            let data = _this.data;
            let flag = !_this.data.flag;;
            _this.setData({
                flag: flag,
                filterActiv: e.currentTarget.dataset.popup,
            });
            if (data.filterActiv == 0) {
                _this.setData({
                    oilLev2: data.oilQuality[data.oilIndex].oilNum,
                })
            }else if (data.filterActiv == 2) {
                _this.setData({
                    storeLev2: data.testStorehouse[data.storeIndex].info,
                })
            }
            console.log(_this.data.filterActiv, _this.data.flag);
        },
        //截取字符串字数大于4，取前面4位加省略号
        sliceString(item) {
            return item.length > 4 ? item.slice(0, 4) + '...' : item;
        },

        tapGBOil(e) {
            let _this = this;
            let data = _this.data;
    
            let itemName = e.currentTarget.dataset.name;
            let buy = '';
    
            if (itemName == '全部') {
                buy = '';
    
            } else {
                buy = _this.sliceString(itemName);
            }
            _this.setData({
                companyActiv: e.currentTarget.dataset.company,
                buyName: buy,
                flag: false
            })
        },
        tapModel(e ){
            let _this = this;
        let data = _this.data;

        let itemName = e.currentTarget.dataset.name;
        let company = '';

        if (itemName == '全部') {
            company = '';

        } else {
            company = _this.sliceString(itemName);
        }
        _this.setData({
            companyActiv: e.currentTarget.dataset.company,
            companyName: company,
            flag: false
        })
        },

        tapStorehouse(e) {
            let storehouse_index = e.currentTarget.dataset.storehouse_index
            let index = storehouse_index != '' ? storehouse_index : 0;
            let _this = this;
            let data = _this.data;

            _this.setData({
                storeLev2: data.testStorehouse[index].info,
                storeIndex: index,
            })
        },

        tapStorehouseItem(e) {
            console.log(e.currentTarget.dataset.store_item, e.currentTarget.dataset.store_item_name);
            let _this = this;
            let data = _this.data;

            let itemName = e.currentTarget.dataset.store_item_name;
            let storeItem = '';

            if (itemName == '全部') {
                storeItem = '';
            } else {
                storeItem = _this.sliceString(itemName);
            }
            _this.setData({
                storeActiv: e.currentTarget.dataset.store_item,
                storeName: storeItem,
                selectName: itemName,
                flag: false
            })


        },

        tapOil(e) {
            let oil_index = e.currentTarget.dataset.oil_index
            let index = oil_index != '' ? oil_index : 0;
            let _this = this;
            let data = _this.data;

            _this.setData({
                oilLev2: data.oilQuality[index].oilNum,
                oilIndex: index,
            })
        },

        tapOilItem(e) {
            console.log(e.currentTarget.dataset.oil_item, e.currentTarget.dataset.oil_item_name);
            let _this = this;
            let data = _this.data;

            let itemName = e.currentTarget.dataset.oil_item_name;
            let oilItem = '';

            if (itemName == '全部') {
                oilItem = '';
            } else {
                oilItem = _this.sliceString(itemName);
            }
            _this.setData({
                oilActiv: e.currentTarget.dataset.oil_item,
                oilName: oilItem,
                oilName: itemName,
                flag: false
            })


        },
        
    }
})
